package ssi.peeno.model;

import java.io.Serializable;

public class Message implements Serializable {
	private String author;
	private double distance;
	private double lon;
	private double lat;
	private double alt;
	private String subject;
	private String text;
	private int id;
	private String type;
	private boolean priv;
	private boolean myMessage;
	
	public String getAuthor() {
		return author;
	}
	
	public void setAuthor(String author) {
		this.author = author;
	}
	
	public double getDistance() {
		return distance;
	}
	
	public void setDistance(double dist) {
		this.distance = dist;
	}
	
	public double getLon() {
		return lon;
	}
	
	public void setLon(double lon) {
		this.lon = lon;
	}
	
	public double getLat() {
		return lat;
	}
	
	public void setLat(double lat) {
		this.lat = lat;
	}
	
	public double getAlt() {
		return alt;
	}
	
	public void setAlt(double alt) {
		this.alt = alt;
	}
	
	public String getSubject() {
		return subject;
	}
	
	public void setSubject(String subject) {
		this.subject = subject;
	}
	
	public String getText() {
		return text;
	}
	
	public void setText(String text) {
		this.text = text;
	}
	
	public int getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}
	
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public boolean isPrivate() {
		return priv;
	}

	public void setPrivate(boolean priv) {
		this.priv = priv;
	}

	public boolean isMyMessage() {
		return myMessage;
	}

	public void setMyMessage(boolean myMessage) {
		this.myMessage = myMessage;
	}

	public String toString() {
		return subject + " " + author + " " + roundDouble(distance, 3);
	}
	
	private double roundDouble(double d, int place) {
		double result = 0;
		result = d * Math.pow(10, place);
		result = Math.round(result);
		return result/Math.pow(10, place);
	}
}